package cn.wenhe9.yygh.order.producer;

import cn.wenhe9.yygh.model.vo.sms.SmsVo;
import cn.wenhe9.yygh.model.vo.user.OrderMqVo;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.messaging.Source;
import org.springframework.messaging.Message;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;


/**
 * @author DuJinliang
 * 2022/4/8
 */
@Component
@EnableBinding(Source.class)
public class OrderProducer {
    @Resource
    private Source source;

    public void sendOrder(OrderMqVo orderMqVo){
        source.output().send(MessageBuilder.withPayload(orderMqVo).setHeader("type", "order").build());
    }

    public void sendSms(SmsVo smsVo){
        source.output().send(MessageBuilder.withPayload(smsVo).setHeader("type", "sms").build());
    }
}
